/*
 * @Author: huang liang miao 1127255342@qq.com
 * @Date: 2024-11-27 16:01:47
 * @LastEditors: luosi 1297957337@qq.com
 * @LastEditTime: 2024-11-28 09:30:00
 * @FilePath: \dcy-webd:\webCode\dcyCode\scientific_research_manager_web\src\api\system\dict\index.ts
 * @Description: 字典数据相关
 */
import request from '@/utils/request'
import {
  DictionaryCreateReqDTO,
  BaseSuccessRespDTO,
  DictionaryPageReqDTO,
  PageBeanDictionaryPageRespVO,
  DictionaryUpdateReqDTO,
  BaseIdReqDTO,
  DictionaryDataPageReqDTO,
  PageBeanDictionaryDataPageRespVO,
  DictionaryDataUpdateReqDTO,
  DictionaryListReqDTO,
  DictionaryListRespVO,
  DictionaryBatchCreateReqDTO,
} from './type'

// 创建字典、字典数据
export function dictionaryCreateApi(data: DictionaryCreateReqDTO) {
  return request<BaseSuccessRespDTO>({
    url: '/base/api/dictionary/create',
    method: 'post',
    data
  })
}

// 字典分页
export function dictionaryPageApi(data: DictionaryPageReqDTO) {
  return request<PageBeanDictionaryPageRespVO>({
    url: '/base/api/dictionary/page',
    method: 'post',
    data
  })
}

// 字典更新
export function dictionaryUpdateApi(data: DictionaryUpdateReqDTO) {
  return request<BaseSuccessRespDTO>({
    url: '/base/api/dictionary/update',
    method: 'post',
    data
  })
}

// 字典删除
export function dictionaryDeleteApi(data: BaseIdReqDTO) {
  return request<BaseSuccessRespDTO>({
    url: '/base/api/dictionary/delete',
    method: 'post',
    data
  })
}

// 字典数据分页
export function dictionaryPageDataApi(data: DictionaryDataPageReqDTO) {
  return request<PageBeanDictionaryDataPageRespVO>({
    url: '/base/api/dictionary/pageData',
    method: 'post',
    data
  })
}

// 字典数据更新
export function dictionaryUpdateDataApi(data: DictionaryDataUpdateReqDTO) {
  return request<BaseSuccessRespDTO>({
    url: '/base/api/dictionary/updateData',
    method: 'post',
    data
  })
}

// 字典数据删除
export function dictionaryDeleteDataApi(data: BaseIdReqDTO) {
  return request<BaseSuccessRespDTO>({
    url: '/base/api/dictionary/deleteData',
    method: 'post',
    data
  })
}

// 字典数据列表
export function dictionaryListApi(data: DictionaryListReqDTO) {
  return request<DictionaryListRespVO[]>({
    url: `/base/api/dictionary/list`,
    method: 'post',
    data
  })
}
// 禁用启用
export function updateDataStatusApi(data: {id: string, status: number}) {
  return request({
    url: `/base/api/dictionary/updateDataStatus`,
    method: 'post',
    data
  })
}

// 字典批量导入
export function batchCreateListApi(data: DictionaryBatchCreateReqDTO) {
  return request({
    url: `/base/api/dictionary/batchCreate`,
    method: 'post',
    responseType: 'blob',
    data
  })
}